import React from 'react';
import './item.scss';
import {imagePrefix} from '~/common/global';

const imgReg = /^images/
export default function Item(props) {
    let {data} = props;
    let {sender, datetime, content} = data;
    return(
        <div className="chat-item">
            <div className="chat-item-header">
                <span>{sender}</span>
                <span>{datetime.split(" ")[1]}</span>
            </div>
            <div className="chat-item-content">
                {imgReg.test(content) ? <img src={imagePrefix + content} alt="图片"/> : content}
            </div>
        </div>
    )
}